class_name SlotComponent
extends BaseComponent
## SlotItem 命名格式：SlotType_XXX pl:Head_0 Weapon_muzzle
var slot_dict:Dictionary

func init_slot_dict():
	slot_dict = {}
	for child in get_children():
		var slot_name = child.name.split("_")[0]
		if GameEnum.SlotType[slot_name] != null and slot_dict.has(GameEnum.SlotType[slot_name]) == false:
			slot_dict[GameEnum.SlotType[slot_name]] = []
			if child.get_child_count() == 0:
				slot_dict[GameEnum.SlotType[slot_name]].append(child)
			else:
				for child_child in child.get_children():
					slot_dict[GameEnum.SlotType[slot_name]].append(child_child)
func get_slot_dict()->Dictionary:
	return slot_dict
func get_slot_by_type(slot:GameEnum.SlotType,index:int = 0)->Node2D:
	var slot_array:Array = slot_dict.get(slot) as Array
	if slot_array == null or index >= slot_array.size():
		return null
	return slot_array[index]

func _init() -> void:
	component_name = "SlotComponent"
func _ready() -> void:
	init_slot_dict()
